#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <netdb.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <arpa/inet.h>

void* tcp_fun(){
	int sockfd,numbytes;
    char buf[BUFSIZ];
    struct sockaddr_in their_addr;
    while((sockfd = socket(AF_INET,SOCK_STREAM,0)) == -1);
    printf("We get the sockfd~\n");
    their_addr.sin_family = AF_INET;
    their_addr.sin_port = htons(8888);
    their_addr.sin_addr.s_addr=inet_addr("192.168.199.149");
    bzero(&(their_addr.sin_zero), 8);			//清空数据中前8位
    
    while(connect(sockfd,(struct sockaddr*)&their_addr,sizeof(struct sockaddr)) == -1);
    printf("Get the Server~Cheers!\n");
    buf[numbytes]='\0';  
    while(1)
    {
        printf("Entersome thing:");
        scanf("%s",buf);
        numbytes = send(sockfd, buf, strlen(buf), 0);
    }
    close(sockfd);
	return NULL;
}



int main(int argc,char *argv[])
{
    pthread_t th1 ;//线程1
	pthread_t th2 ；
	pthread_create(&th1,NULL,myfun,NULL);
	pthread_create(&th2,NULL,myfun,NULL);
	pthread_join(th1,NULL)
	pthread_join(th2,NULL)
	
    return 0;
}